package de.fu_berlin.minesweeper;

/**
 * Position class
 */
public class Position {
	
	private boolean isBomb, bRevealed;
	private int intBombNeighbours;
	
	/**
	 * Creates a field instance
	 * @param isBomb
	 */
	public Position(boolean isBomb){
		this.isBomb = isBomb;
		this.bRevealed = false;
		this.intBombNeighbours = 0;
	}
	
	/**
	 * Returns true, if field was already played 
	 * @return boolean value
	 */
	public boolean revealed(){
		return this.bRevealed;
	}
	
	/**
	 * Reveals the field and marks it as played
	 */
	public void reveal(){
		this.bRevealed = true;
	}
	
	/**
	 * Returns true, if field is a bomb
	 * @return boolean value
	 */
	public boolean isBomb(){
		return this.isBomb;
	}
	
	/**
	 * Gets the amout of neighbours, who are bombs
	 * @return integer value
	 */
	public int getBombNeighbours(){
		return this.intBombNeighbours;
	}
	
	protected void setBombNeighbours(int intNum){
		this.intBombNeighbours = intNum;
	}
	
	@Override
	public String toString(){
		if (this.bRevealed == false){
			return "X";
		}else{
			if(this.isBomb == false) 
                	return Integer.toString(this.intBombNeighbours); 
            else	return "B"; 
		}
	}
}
